library(shiny)

shinyUI(pageWithSidebar(
  headerPanel('Heart disease predictor'),
  sidebarPanel(
    sliderInput(inputId = "age",
                label = "1. Age (years)",
                min = 29,
                max = 77,
                value = 60),
    radioButtons(inputId = "sex",
                 label = "2. Gender",
                 choices = list("Male" = 1,
                                "Female" = 0)),
    selectInput(inputId = "chestpain",
                 label = "3. 4-valued chest pain type",
                 choices = list("Type 1" = 1,
                                "Type 2" = 2,
                                "Type 3" = 3,
                                "Type 4" = 4)),
    sliderInput(inputId = "restbp",
                label = "4. Resting blood pressure (beats per minute)",
                min = 94,
                max = 200,
                value = 130),
    sliderInput(inputId = "chol",
                label = "5. Serum cholesterol (mg/dl)",
                min = 126,
                max = 564,
                value = 322),
    radioButtons(inputId = "sugar",
                 label = "6. Is the fasting blood sugar level > 120 mg/dl",
                 choices = list("Yes" = 1,
                                "No" = 0)),
    selectInput(inputId = "ecg",
                label = "7. 3-valued resting electrocardiographic results",
                choices = list("Result 1" = 0,
                               "Result 2" = 1,
                               "Result 3" = 2)),
    sliderInput(inputId = "maxhr",
                label = "8. Maximum heart rate achieved (beats per minute)",
                min = 71, 
                max = 202,
                value = 110),
    radioButtons(inputId = "angina",
                 label = "9. Was angina induced by exercise?",
                 choices = list("Yes" = 1,
                                "No" = 0)),
    sliderInput(inputId = "dep",
                label = "10. ST depression induced by exercise relative to rest",
                min = 0,
                max = 6.2,
                value = 1.5,
                step = 0.1),
    selectInput(inputId = "exercise",
                label = "11. Slope of the peak exercise ST segment",
                choices = list("Result 1" = 1,
                               "Result 2" = 2,
                               "Result 3" = 3)),
    sliderInput(inputId = "fluor",
                label = "12. The number of major vessels colored by fluoroscopy",
                min = 0,
                max = 3,
                value = 3),
    selectInput(inputId = "thal",
                label = "13. 3-valued Thal",
                choices = list("Value 1" = 3,
                               "Value 2" = 6,
                               "Value 3" = 7))
  ),
  mainPanel(
    h3('Your risk of heart disease is:'),
    textOutput('riskLevel'),
    plotOutput('heartFigure',width = 'auto', height = '600px')
  )
))
